<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link th:href="@{/erp/assets/css/bootstrap.min.css}" rel="stylesheet"/>
    <link rel="stylesheet" th:href="@{/erp/css/style.css}"/>
    <link th:href="@{/erp/assets/css/codemirror.css}" rel="stylesheet">
    <link rel="stylesheet" th:href="@{/erp/assets/css/ace.min.css}"/>
    <link rel="stylesheet" th:href="@{/erp/assets/css/font-awesome.min.css}"/>
    <script th:src="@{/erp/assets/js/jquery.min.js}"></script>
    <script th:src="@{/erp/assets/js/bootstrap.min.js}"></script>
    <!-- page specific plugin scripts -->
    <script th:src="@{/erp/assets/js/jquery.dataTables.min.js}"></script>
    <script th:src="@{/erp/assets/js/jquery.dataTables.bootstrap.js}"></script>
    <script th:src="@{/erp/assets/layer/layer.js}" type="text/javascript"></script>
</head>
<body>
<div class="add_menbe" id="add_menber_sty">
    <form>
        <ul class=" page-content">
            <table id="sample-table" class="table table-striped table-bordered table-hover">
                <thead>
                <tr>
                    <th width="150">订单编号</th>
                    <th width="170">激光码</th>
                </tr>
                </thead>
                <tbody>
<!--                <tr th:each="x : ${codeList}">-->
<!--                    <td th:text="${x.orderNo}"></td>-->
<!--                    <td th:text="${x.olCode}"></td>-->
<!--                </tr>-->
                </tbody>
            </table>
        </ul>
        <div class="" style=" text-align:center">
            <input class="btn btn-primary" id="btn_sure" type="button" value="确认">
            <input class="btn btn-primary" id="btn_qx" type="reset" value="取消">
        </div>
    </form>
</div>
<script>
    $(function () {

        var table = $('#sample-table').dataTable({
            "autoWidth": false,//当重复刷新表格时，我的页面会出现变形的，现象，加了这个就好了
            searching: false,
            serverSide: true,   //开始服务器分页
            destroy:true,
            ajax: {
                url: '/laser/RShowLaser?orderId='+'[[${orderId}]]'+'',
                type: 'post',
                dataSrc: 'data',
                data: function (message) {

                    var data = $('form').serialize();   //获取查询条件

                    //获取分页信息
                    var pages = {
                        start: message.start,

                        length: message.length,
                    };
                    data = data + '&' + $.param(pages);
                    return data;

                }
            },
            columnDefs: [{"defaultContent": "",
                "targets": "_all"}],
            columns: [
                {"data": "orderNo"},
                {"data": "olCode"}
            ]
        });





        $('#btn_sure').on('click', function () {
            $.get('/laser/addCode', function (res) {
                console.log(res.rs);
                if (res.rs) {
                    parent.location.reload();
                    parent.layer.msg(res.msg, {icon: 1});
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            })
        })

        $('#btn_qx').on('click', function () {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
            parent.layer.close(index); //再执行关闭
        });
    })

</script>
</body>
</html>